import java.util.*;

public class Test {
    String[] scoresort(String[] names ,String[] scores ){
        int re,n=names.length;
        HashMap<Integer,String> hash=new HashMap<>();
        String[] res=new String[n];
        Integer[] arr= new Integer[n];
        //int[] arr= new int[n];
        for (int i = 0; i < n; i++) {
            re=0;
            String[] strs=scores[i].split(",");
            for(String x:strs){
               re+=Integer.parseInt(x) ;
            }
            hash.put(re,names[i]);
            arr[i]=re;
        }
//        Arrays.sort(arr, ( Integer a, Integer b) -> { return b-a;});
        Arrays.sort(arr, (  a,  b) -> ( b-a ));
        Arrays.sort(arr, Collections.reverseOrder());
        for (int i = 0; i < n; i++){
            res[i]=hash.get(arr[i]);
        }
       return  res;
    }
}